<template>
	<view class="container">
		<view >
		<view class="home_li">
			<view><text>家庭编号</text></view>
			<view class="home_id"><input class="inputs" v-model="name" /></view>
		</view>
		<view class="home_li">
			<view><text>门状态</text></view>
			<view class="home_id"><text>开</text></view>
		</view>
		</view>
		
		
		
		
		<view class="Submit">
			<button class="button" width="90%" form-type="submit" @click="deletes()" type="primary">移除</button>
		</view>
		<view class="Submit">
			<button class="button" width="90%" form-type="submit" @click="reset()" type="primary">恢复出厂设置</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				deviceId: '',
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			this.deviceId = option.deviceId;
			console.log("设备id",this.deviceId)
			this.name = option.name
		},

		methods: {
			deletes() {
				try {
					uni.showLoading({
						title: '子设备正在删除中'
					});
					const deviceManageModule = uni.requireNativePlugin("LJY-DeviceManageModule"); //调用android中自定义的插件名称
					const ret = deviceManageModule.removeDevice({ //login表示自定义插件的函数名，第一个表示要传递的参数
						deviceId: this.deviceId
					});
					uni.hideLoading(); //加载结束
					if (ret.code == 0) {
						uni.navigateBack({
							url: '/pages/house/equipment/eqList'
						})
					} else { //加载失败
						uni.showToast({
							title: ret.msg,
							duration: 2000
						});
					}
				} catch (e) { //如果涂鸦智能无法连接
					uni.hideLoading(); //加载结束
					uni.showToast({
						title: '子设备删除失败,请稍后再试',
						duration: 2000
					});
				}
			},
			reset() {
				try {
					uni.showLoading({
						title: '子设备正在重置中'
					});
					const deviceManageModule = uni.requireNativePlugin("LJY-DeviceManageModule"); //调用android中自定义的插件名称
					const ret = deviceManageModule.resetDevice({ //login表示自定义插件的函数名，第一个表示要传递的参数
						deviceId: this.deviceId
					});
					uni.hideLoading(); //加载结束
					if (ret.code == 0) {
						uni.navigateBack({
							url: '/pages/house/equipment/eqList'
						})
					} else { //加载失败
						uni.showToast({
							title: ret.msg,
							duration: 2000
						});
					}
				} catch (e) { //如果涂鸦智能无法连接
					uni.hideLoading(); //加载结束
					uni.showToast({
						title: '子设备重置失败,请稍后再试',
						duration: 2000
					});
				}
			}
		}
	}
</script>

<style lang="less" >
	.home {
		// background-color: #007AFF;
		width: 100%;
		height: 300rpx;
	}

	.home_li {
		// background-color: #555555;
		height: 80rpx;
		width: 95%;
		margin-left: 20rpx;
		display: flex;
		position: relative;
		// align-items: center;
		line-height: 80rpx;
		border-bottom: 2rpx solid #020202;

		.home_id {
			position: absolute;
			right: 0;
			// background-color: #3C96FF;
		}
	}

	.button {
		margin-top: 20rpx;
		margin-left: 30rpx;
	}
	.inputs{
		height: 80rpx;
	}
</style>
